Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a prototype for lazy loading support (ticket #97). The main idea behind this PR is to support commands which are lazy wrappers around another command (as in, will lazily load the real command when needed). This helps reduce unnecessary module importing, by only importing when the command is needed. In practice, this means using the click.Command functions to fetch info about the command, instead of its fields (
get_params()call instead of just reading theparamsfield). The changes made were:test_lazy_command.py, an interactive test script which runs trogon on a fake CLI that uses lazy loading. Should demonstrate:cmd_1andcmd_2) until the user tries to view them in the appCommandSchemato be an abstract class instead of a data class, so that we can write custom properties in derived classesClickCommandSchemaclass inheritingCommandSchema, which lazily provides the values of its properties using almost identical logic to the belowintrospect_click_app()function which used to constructCommandSchemaobjects on its ownclick.Contextobject is required for many of theclick.Commandfunction calls, so passed that object from the creation of the Trogon app down into the creation ofClickCommandSchemarun_if_no_command: boolargument to maintui()call. Normally if the root command is called, it will show help information for the CLI. If therun_if_no_commandflag is enabled, instead of printing the help text, it will run the trogon app.